﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="style.css" />
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 	<script src="../static/js/jquery.js"></script>
</head>

<!-- partial:index.partial.html -->
<body>
    <div class="container">
        <div class="top">
            <h1>开通注册</h1>
        </div>
        <div class="package-container">
            <div class="packages">
                <h1>年度缴费</h1>
                <h2 class="text1">￥365</h2>
                <a href="#" class="button button1" onclick="pay(1)">立即开通</a>
            </div>
            <div class="packages">
                <h1>半年缴费</h1>
                <h2 class="text1">￥270</h2>
                <a href="#" class="button button2" onclick="pay(2)">立即开通</a>
            </div>
            <div class="packages">
                <h1>季度缴费</h1>
                <h2 class="text1">￥180</h2>
                <a href="#" class="button button3" onclick="pay(3)">立即开通</a>
            </div>
        </div>
    </div>
    <script src="./script.js"></script>
</body>
<!-- partial -->
<script src="./script.js"></script>
<script type="text/javascript">
function pay(type){
    $.ajax({
        url:"../Pay",
        type:"post",
        data:{type:type},
        //十分重要，不能省略
        success: function (res,status) {
        	var data = JSON.parse(res);
        	if(status=="success"&&data.status=="success"){
        		var info = data.data;
        		 WeixinJSBridge.invoke(
        			      'getBrandWCPayRequest', {
        			         "appId":info.appId,     //公众号ID，由商户传入     
        			         "timeStamp":info.timestamp,         //时间戳，自1970年以来的秒数     
        			         "nonceStr":info.nonceStr, //随机串     
        			         "package":info.packageValue,     
        			         "signType":info.signType,         //微信签名方式：     
        			         "paySign":info.paySign //微信签名 
        			      },
        			      function(res){
        			      if(res.err_msg == "get_brand_wcpay_request:ok" ){
        			      // 使用以上方式判断前端返回,微信团队郑重提示：
        			            //res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
        			      } 
        			   }); 
        	}
        	else{
        		alert(data.msg);
        	}
           // alert(JSON.stringify(res.data));
        }
    });
}
</script>
</html>
